project( helloWorld )

add_compile_options(-Wl,-rpath=./) #同目录下查找动态链接库

#aux_source_directory 是将目录下所有的cpp文件加到src变量中，即其不对头文件生效
#aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} src)

set( src
    ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
)

include_directories(
    ${CMAKE_SOURCE_DIR}/outLib
    ${CMAKE_CURRENT_SOURCE_DIR}/../staticLibTest
)

#添加外部库时，外部库的路径在此处添加,link_directories必须写在add_executable的前面
link_directories ( ${CMAKE_SOURCE_DIR}/outLib )
#添加外部库时，推荐使用find_library这种方式
#find_library(ActiveMQ_LIB activemq-cpp HINTS ${CMAKE_SOURCE_DIR}/../3rdParty/lib/arm/ActiveMq)

set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/../build)

#find_library(staticTest_lib staticLibTest HINTS ${CMAKE_SOURCE_DIR}/../build)
add_executable(${PROJECT_NAME} ${src})

#若是外部库，外部库的名字需要添加双引号, target_link_libraries必须写在add_executable的后面
target_link_libraries(
    ${PROJECT_NAME}
    OutLib
    staticLibTest
    #shareLibTest
    #shareLibTest2
    #${ActiveMQ_LIB}
)

set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/../install)
install(TARGETS helloWorld
         RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX})

SET(BUILD_PLATFORM "arm" CACHE STRING "select build cpu type")
 # 外部用cmake . -DBUILD_PLATFORM=arm进行值传入，便可以执行不同的逻辑
# cmake反逻辑的写法在前面加个NOT，如“if (NOT BUILD_PLATFORM STREQUAL arm)”
if (BUILD_PLATFORM STREQUAL arm)
  message("this is arm platform")
else()
  message("this is x86 platform")
endif()

# execute_process中的cp指令不能用*这样的通配符，所以第2句话无效
#execute_process(COMMAND cp /home/wenke/test/222.txt /home/wenke/)
#execute_process(COMMAND cp /home/wenke/test/* /home/wenke/)

option(USE_AEC "Set to switch to build use AEC"  OFF)
# 外部用cmake . -DUSE_AEC=ON进行值传入，便可以执行不同的逻辑
if (USE_AEC) #根据宏开关判断逻辑
    message("use aec to restrict audio echo")
else()
    message("do not use aec")
endif()

aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} ALL_SOURCE)
message("ALL_SOURCE is ${ALL_SOURCE}")
file(GLOB ALL_SOURCE2 "*.cpp" "*.c")
message("ALL_SOURCE2 is ${ALL_SOURCE2}")

